<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data" ></cfg-form>
</template>

<script>
export default {
  name:'pg-form',
  components: {},
  inject:['anc'],
  data() {
    return {
        ref:'form'
    };
  },
  props: {
    data:{
        default:()=>{
            return {};
        }
    }
  },
  watch: {},
  computed: {
    attrs(){
        return {
            labelWidth: 100,
            labelPosition: 'right',
            cols: 3,
            columns: [
                {
                    key: 'type',
                    title: '所属类型',
                    minWidth: 100,
                    align: 'center',
                    show: true
                },
                {
                    key: 'className',
                    title: '模型类名',
                    minWidth: 100,
                    align: 'center',
                    show: true
                }
            ],
            rules:{
                type: [
                    { required: true, message: '请输入所属类型', trigger: 'blur' }
                ],
                className: [
                    { required: true, message: '请输入模型类名', trigger: 'blur' }
                ]
            },
            onlyRead:false

        }
    }
  },
  created() {},
  mounted() {
    this.$nextTick(()=>{
      this.$set(this.anc.vms,this.ref, this);
    })
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if(fn) {
          return fn(valid)
        }else{
          return valid;
        };
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  }
};
</script>
<style scoped>
</style>